import './modules/handle-dom.js'
import './modules/video.js'

const setting = JSON.parse(localStorage.getItem("setting"))
const config = { childList: true, subtree: true };
const observer = new MutationObserver((mutationsList, observer) => {
  for (let mutation of mutationsList) {
    if (mutation.type === 'childList') {
      for (let addedNode of mutation.addedNodes) {
        if (addedNode instanceof HTMLElement && addedNode.classList.contains('layui-layer-dialog')) {
          console.log(addedNode, '检测到弹窗显示');
          $(`div.layui-layer-btn.layui-layer-btn- > a`).click()
        }
      }
    }
  }
});
const targetNode = document.body; // 选择要观察的目标节点，这里选择整个文档的 body 元素
observer.observe(targetNode, config); // 将观察器绑定到目标节点上

if (window === window.top) {
  if (setting.alert) {
    //todo))研究该属性去除30分钟弹框
    jQuery.studyTime.options.clickAuth = false;
  }
  console.log(window.MultiPageEventBus);
  MultiPageEventBus.on('updateSetting', (param) => {
    localStorage.setItem('setting', param);
    ElMessage({
      type: 'success',
      message: "配置修改成功"
    })
  })
}